package logic

import (
	"MyBlogs/dao/mysql"
	"MyBlogs/models"
	"MyBlogs/pkg/session"
	"github.com/gin-gonic/gin"
)

func GetAdmin(context *gin.Context) {
	var admin models.Manage
	err := context.ShouldBind(&admin)
	if err != nil {

	}
	adm := mysql.GetAdmin(admin.Name)

	if adm.Name == admin.Name && adm.Password == admin.Password {
		_ = session.SetAdminSession(context, admin.Name, adm.Id)
		context.JSON(200, gin.H{
			"data": "登录成功!",
		})
	}

}
